/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.imenu.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Yunzi
 */
@Entity
@Table(name = "imenu_order_item")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ImenuOrderItem.findAll", query = "SELECT i FROM ImenuOrderItem i"),
    @NamedQuery(name = "ImenuOrderItem.findById", query = "SELECT i FROM ImenuOrderItem i WHERE i.id = :id"),
    @NamedQuery(name = "ImenuOrderItem.findByOrderId", query = "SELECT i FROM ImenuOrderItem i WHERE i.orderId = :orderId"),
    @NamedQuery(name = "ImenuOrderItem.findByCourseId", query = "SELECT i FROM ImenuOrderItem i WHERE i.courseId = :courseId"),
    @NamedQuery(name = "ImenuOrderItem.findByCourseName", query = "SELECT i FROM ImenuOrderItem i WHERE i.courseName = :courseName"),
    @NamedQuery(name = "ImenuOrderItem.findByCoursePrice", query = "SELECT i FROM ImenuOrderItem i WHERE i.coursePrice = :coursePrice"),
    @NamedQuery(name = "ImenuOrderItem.findByCreateTime", query = "SELECT i FROM ImenuOrderItem i WHERE i.createTime = :createTime")})
public class ImenuOrderItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id", insertable=false)
    private Integer id;
    @Column(name = "course_id")
    private Integer courseId;
    @Size(max = 40)
    @Column(name = "course_name")
    private String courseName;
    @Column(name = "course_price")
    private Integer coursePrice;
    @Column(name = "create_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    @JoinColumn(name = "order_id", referencedColumnName = "id")
    @ManyToOne(optional = false, cascade={CascadeType.MERGE})
    private ImenuOrder orderId;

    public ImenuOrderItem() {
    }

    public ImenuOrderItem(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public ImenuOrder getOrderId() {
        return orderId;
    }

    public void setOrderId(ImenuOrder orderId) {
        this.orderId = orderId;
    }

    public Integer getCourseId() {
        return courseId;
    }

    public void setCourseId(Integer courseId) {
        this.courseId = courseId;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public Integer getCoursePrice() {
        return coursePrice;
    }

    public void setCoursePrice(Integer coursePrice) {
        this.coursePrice = coursePrice;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ImenuOrderItem)) {
            return false;
        }
        ImenuOrderItem other = (ImenuOrderItem) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.imenu.entity.ImenuOrderItem[ id=" + id + " ]";
    }
    
}
